package com.woniuxy.jwt;


import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

//解析Jwt字符串令牌
public class ParseJwt {
    public static void main(String[] args) {
        String token="eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI2NjYiLCJzdWIiOiJhZG1pbiIsImlhdCI6MTY0NTUyNzk4MiwiZXhwIjoxNjQ1NTI4MDQyLCJ1c2VybmFtZSI6ImxpcGVpbGluIiwicGFzc3dvcmQiOjEyMzQ1Nn0.YMHV0ni6tNUUMtqrtHnS0HOpM0LreOnl4ZN434lnT7Y";

        Claims claims=
                Jwts.parser().setSigningKey("woniuxy").parseClaimsJws(token).getBody();
        System.out.println(claims.getId());
        System.out.println(claims.getSubject());
        System.out.println(claims.getIssuedAt());
        System.out.println(claims.get("username"));
        System.out.println(claims.get("password"));
    }
}
